<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BUIService
 *
 * @author jianfeng
 */
class BUIService extends BUINode {

    public $layoutView = null;
    public $views = null;

    public function __construct($node = NULL) {
        parent::__construct($node);
        $this->service = $node;

        $uiPath = $node->uiPath;

        if ($this->viewPath == NULL)
            $this->viewPath = $uiPath . ".themes." . Blyn::app()->getAppUI()->getTheme() . '.views';

        if ($this->formPath == NULL)
            $this->formPath = $uiPath . ".themes." . Blyn::app()->getAppUI()->getTheme() . '.forms';
    }

    public function render($data = null) {

        parent::render();

        // if ($this->currentScreen == NULL)
        //     $this->currentScreen = "BScreenService";
        //array_push($this->renderScreens, $this->currentScreen);

        $this->views['topBar'] = array('view' => 'serviceTopBar', 'data' => array('uiObj' => $this));

        $this->gotoUINode($this->getId(), $this->getNode()->getServiceEngine()->getId());
    }

    public function getViews() {
        if ($this->views == NULL) {
            $this->views = array();
        }

        return $this->views;
    }

    public function getLayoutView() {
        if ($this->layoutView == NULL)
            $this->layoutView = 'serviceLayout2';

        return $this->layoutView;
    }

    public function getName() {
        return $this->service->getName();
    }

    public function renderCreateService($config = null) {
        //$screenName = isset($_POST['bilyn_screen_name'])?$_POST['bilyn_screen_name']:'CreateServiceMeta';
        //return $this->gotoScreen($screenName,$this,$config,$style);
        return $this->gotoScreenFlow('BScreenCreateService', $this, $config);
    }

    public function renderJoinService($config = null) {
        return $this->gotoScreen('BScreenJoinService', $this, $config);
    }

    public function getUrl($data = NULL) {
        $ajaxUrl = $this->getAjaxUrl($data);

        if ($ajaxUrl != NULL)
            return $ajaxUrl;
        return $this->buildUrl($this->service->getId(), NULL, NULL, $data);
    }

}

?>
